// go get github.com/json-iterator/go
package main

import (
	"fmt"
	jsoniter "github.com/json-iterator/go"
)

type User struct {
	Name string `json:"name,omitempty"`
	Age  int8   `json:"age,omitempty"`
}

func main() {
	var json = jsoniter.ConfigCompatibleWithStandardLibrary
	u := User{
		Name: "tom",
		Age:  22,
	}
	data, err := json.Marshal(&u)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(string(data))

	data2 := []byte(`{"name":"jerry","age":26}`)
	u2 := &User{}
	err = json.Unmarshal(data2, u2)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Printf("%+v\n", u2)
}
